package com.keven.caculate.controller;

import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.concurrent.locks.ReentrantLock;

@Configuration
public class ConfigurationTest {

    public ConfigurationTest(){
        System.out.println("beans init success");
    }

    @Bean
    public Person initPerson(){
        Person person = new Person();
        person.setAge(18);
        person.setName("person bean");
        return person;
    }
}

class Test{
    public static void main(String[] args) {
        AnnotationConfigApplicationContext anno =
                new AnnotationConfigApplicationContext(ConfigurationTest.class);

        Person bean = anno.getBean(Person.class);
        System.out.println(bean.toString());

        // 加锁方式
        ReentrantLock reen = new ReentrantLock();
        reen.lock();
    }
}
